﻿<%@ Page Title="Create" Language="C#" MasterPageFile="~/Posts/Posts.master" AutoEventWireup="true" CodeFile="Create.aspx.cs" Inherits="Posts_Create" %>

<asp:Content ID="Content1" ContentPlaceHolderID="phHead" Runat="Server">
<script type="text/javascript">

    $(document).ready(function() {

        $("#ctl00_ctl00_phMain_phMain_dvCreate_-1_0_txt").blur(function() {
            
            var txtUrl = $("#ctl00_ctl00_phMain_phMain_dvCreate_-1_1_txt");
            if (txtUrl.val() == "~")
                return;
            var Url = $(this).val()
            // remove leading and trailing " "
            Url = Url.replace(/^\s+/gi, "");
            Url = Url.replace(/\s+$/gi, "");

            // remove non alphanum, hypen, underscores
            Url = Url.replace(/[^a-zA-Z0-9_\-\s]/gi, "");

            // replace " " with "-"
            Url = Url.replace(/\s/gi, "-");

            // remove multiple "-"
            Url = Url.replace(/-{2,}/gi, "-");
            txtUrl.val(Url);
        });
    });
    
    </script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="phMain" Runat="Server">
    <asp:Panel ID="pnlInsert" CssClass="tabPage clearfix" runat="server">
        <div class="actionButtons clearfix">
            <div class="floatRight">    
                <acms:ActionButton ID="btnSave" CausesValidation="true" Icon="Save" Text="Create Post" OnClick="btnSave_Click" runat="server" />
                <acms:ActionButton ID="btnCancel" CausesValidation="false" Icon="Cancel" Text="Cancel" OnClick="btnCancel_Click" runat="server" />
            </div>
        </div>    

        <asp:Panel ID="pnlParent" CssClass="itemPanel" runat="server">
            <ul class="form">
                <li>
                    <asp:Label ID="Label1" Font-Bold="true" AssociatedControlID="lblParentName" Text="Parent Name: " runat="server" />
                    <asp:Label ID="lblParentName" Font-Italic="true" runat="server" />
                </li>
                <li>
                    <asp:Label ID="Label3" Font-Bold="true" AssociatedControlID="lblParentPath" Text="Parent Path: " runat="server" />
                    <asp:Label ID="lblParentPath" Font-Italic="true" runat="server" />
                </li>
            </ul>
            
        </asp:Panel>
        <asp:DetailsView ID="dvCreate" DataSourceID="dsPost" AutoGenerateRows="False" 
            DefaultMode="Insert" runat="server" ondatabound="dvCreate_DataBound" 
            oniteminserted="dvCreate_ItemInserted">
            <Fields>
                
                <acms:TextBoxField HeaderText="Display Name" DataField="DisplayName" Required="true" HelpText="The name of this new Post. This is how it will appear in page titles, menus etc."/>
                
                <acms:TextBoxField DataField="Name" HeaderText="URL Safe Name" ReadOnly="true" Required="true" HelpText="The URL-safe name for this Post, e.g. ~/parentpath/<b><i>Name</i></b>. It can be set automatically if you enter a Display Name above." />
                
                <acms:DropDownField HasEmptyValue="True" DataSourceId="dsTemplates" HelpText="Select the template you want this new Post to use." DataTextField="Name" DataValueField="Id" Required="True" HeaderText="Template" DataField="TemplateId" />
               <%-- <acms:TextAreaField DataField="Summary" HeaderText="Summary" Cols="50" 
                    Rows="10" />--%>
                <acms:TextAreaField HeaderText="Notes" DataField="Notes" Cols="50" Rows="10" HelpText="Notes allow you to leave comments about this Post for other users of the CMS to read." />
            </Fields>
        </asp:DetailsView>
    </asp:Panel>
    <asp:Panel ID="pnlRootExists" CssClass="ImportantText itemPanel " Visible="false" runat="server">
        There is already a Home page for this site. Please use the tree to select a parent post.
    </asp:Panel>
    <asp:Panel ID="pnlNoParent" CssClass="ImportantText itemPanel" Visible="false" runat="server">
        The parent for this post cannot be found. Please use the tree to select a parent post.
    </asp:Panel>
    <asp:Panel ID="pnlNoTemplate" CssClass="ImportantText itemPanel" Visible="false" runat="server">
        The parent template for this post does not allow children.
    </asp:Panel>
    <acms:PostDataSource ID="dsPost" runat="server" onupdatingdata="dsPost_UpdatingData" />
    <acms:TemplateDataSource ID="dsTemplates" runat="server" onselectdata="dsTemplates_SelectData" />
</asp:Content>